import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { connect } from 'react-redux'
import { Button } from 'antd-mobile-rn';
import { Colors, AppStyles } from '../../style';
import { NavigationActions, createAction } from '../../common/utils';

@connect(({app})=>({app}))
export default class Welcome extends Component {

    componentWillMount(){
        this.props.dispatch(createAction('app/launchApp')());
    }

    render() {
        return (<View style={{ flex: 1, justifyContent: 'flex-end', alignItems: 'center', }}>
            {this.props.app.showLogin&&<View style={{ width: 300, marginBottom: 150 }}>
                <Button style={{ backgroundColor: Colors.black, }} size={'large'} onClick={() => {
                    console.log('登录')
                    this.props.dispatch(NavigationActions.navigate({routeName:'Login'}))
                }}>
                    <Text style={AppStyles.bigWhiteTextStyle}>我有账号</Text>
                </Button>
                <View style={{ height: 10 }} />
                <Button style={{ backgroundColor: Colors.black, }} size={'large'} onClick={() =>{
                    console.log('注册')
                    this.props.dispatch(NavigationActions.navigate({routeName:'Register'}))
                }}>
                    <Text style={AppStyles.bigWhiteTextStyle}>没有账号</Text>
                </Button>
            </View>}
        </View>)
    }
}